package com.token.base;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

/**
 * 公共操作
 * @author chenjianxiong
 */
public class Pl {
    public static int getSysId(){
        return 1;
    }

    /**
     * 计算时间和现在的时间差
     * @param dt 日期时间
     * @return String
     */
    public static String timeDifferentDaytime(String dt){
        String timeDifferentDaytime = null;
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try{
            Date now = new Date();
            Date date = df.parse(dt);
            long l= now.getTime() - date.getTime();
            long day=l/(24*60*60*1000);
            long hour=(l/(60*60*1000)-day*24);
            long min=((l/(60*1000))-day*24*60-hour*60);
            //long s=(l/1000-day*24*60*60-hour*60*60-min*60);
            timeDifferentDaytime = "" + day + "天" + hour + "小时" + min + "分";
        } catch (Exception e) {
            e.printStackTrace();
        }
        return timeDifferentDaytime;
    }

    /**
     * 获取当前时间
     * @return String ：yyyy-MM-dd HH:mm:ss
     */
    public static String getCurDataTime(){
        return getCurDataTime("yyyy-MM-dd HH:mm:ss");
    }
    /**
     * 获取当前时间
     * @param format 自定义显示格式
     * @return String
     */
    public static String getCurDataTime(String format){
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(new Date());
    }

    /**
     * 获取UUID
     * @return UUID
     */
    public static String getUuid(){
        return UUID.randomUUID().toString().replaceAll("-","");
    }
}
